<%-- 
    Document   : XemDanhSachThanhVienSubpage
    Created on : May 14, 2011, 2:18:30 PM
    Author     : ToanNhan
--%>

<%@page import="java.util.List"%>
<%@page import="Pojos.ThanhVien"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../js/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="script/XemDanhSachThanhVien.js"></script>

<%request.setCharacterEncoding("UTF-8");%>
<center>
    <div style="width:90%; text-align: center; padding: 20px; margin: 10px 0px 10px 0px;">
        <font size="5" color="blue">Danh Sách Thành Viên</font>
    </div>
    <div class="box" style="width:90%;text-align: right; padding: 20px; margin: 10px 0px 10px 0px;">
        <a style="margin-right: 3px;" href="/WebsiteBanHang/Admin/ThemThanhVien.jsp" id="toolbarNew">
            <img alt="Thêm mới" width="32px" height="32px" src="/WebsiteBanHang/images/icon-new.png" />
        </a>
        <a href="#" style="margin-right: 3px;" id="toolbarEdit"><img alt="Chỉnh sửa" width="32px" height="32px" src="/WebsiteBanHang/images/icon-edit.png" /></a>
        <img height="30px" width="2px" src="/WebsiteBanHang/images/divider.jpg"/>        
        <a style="margin-right: 3px;" href="#" id="toolbarBlock"><img alt="Block" width="32px" height="32px" src="/WebsiteBanHang/images/icon-block.png" /></a>
        <a style="margin-right: 3px;" href="#" id="toolbarUnBlock"><img alt="UnBlock" width="32px" height="32px" src="/WebsiteBanHang/images/icon-unblock.png" /></a>
    </div>
    <div class="box" style="width: 90%; padding: 20px;">
        <center>
            <form method="POST" action="/WebsiteBanHang/XemDanhSachThanhVienControler" id="submitForm">
                <input type="hidden" name="command" value="" id="command"/>
                <table width="100%" border="1px">
                    <tr bgcolor="blue" >
                        <td align="center" width="30px">
                            <font color="white">&nbsp;</font>
                        </td>
                        <td align="center" width="150px">
                            <font color="white">Tên đăng nhập</font>
                        </td>
                        <td align="center" width="200px">
                            <font color="white">Họ tên</font>
                        </td>
                        <td align="center" width="200px">
                            <font color="white">Email</font>
                        </td>
                        <td align="center" width="100px">
                            <font color="white">Nhóm</font>
                        </td>
                        <td align="center" width="100px">
                            <font color="white">Tình trạng</font>
                        </td>
                    </tr>

                    <%
                                List<ThanhVien> lstThanhVien = (List<ThanhVien>) request.getAttribute("danhSachThanhVien");
                                if (lstThanhVien != null) {
                                    for (int i = 0; i < lstThanhVien.size(); i++) {
                                        ThanhVien tv = lstThanhVien.get(i);
                                        if (i % 2 == 0) {
                    %>

                    <tr>
                        <%                                    } else {
                        %>
                    <tr bgcolor="bisque">
                        <%}%>
                        <td align="center">
                            <input type="checkbox" id="chk" name="chk" value="<%=tv.getUserName()%>"/>
                        </td>
                        <td align="left" style="margin-left: 2px;">
                            <a href="/WebsiteBanHang/Admin/CapNhatThongTinThanhVien.jsp?userName=<%=tv.getUserName()%>"><%=tv.getUserName()%></a>
                        </td>
                        <td align="left" style="margin-left: 2px;">
                            <%=tv.getHoTen()%>
                        </td>
                        <td align="left" style="margin-left: 2px;">
                            <%=tv.getEmail()%>
                        </td>
                        <td align="left" style="margin-left: 2px;">
                            <%=tv.getNhomThanhVien().getTenNhomThanhVien()%>
                        </td>
                        <td align="left" style="margin-left: 2px;">
                            <%
                                                                    if (tv.getTinhTrang() == ThanhVien.BLOCK_THANHVIEN) {
                                                                        out.print("Bị khóa");
                                                                    } else {
                                                                        out.print("Bình thường");
                                                                    }
                            %>
                        </td>
                    </tr>
                    <%
                                    }
                                }
                    %>
                </table>
            </form>
            <br/>
            <br/>
            Trang số: <%
                        int trangSo = 1;
                        if (request.getAttribute("trangSo") != null) {
                            trangSo = Integer.valueOf((String) request.getAttribute("trangSo"));
                        }
                        int tongSoTrang = 1;
                        if (request.getAttribute("tongSoTrang") != null) {
                            tongSoTrang = Integer.valueOf((String) request.getAttribute("tongSoTrang"));
                        }
                        for (int i = 0; i < tongSoTrang; i++) {
                            if ((i + 1) == trangSo) {
                                out.print((i + 1));
                            } else {
            %>
            <a href="/WebsiteBanHang/Admin/XemDanhSachThanhVien.jsp?command=LayDanhSachThanhVien&trangSo=<%=(i + 1)%>"><%=(i + 1)%></a>
            <%
                            }
                        }
                        request.setAttribute("danhSachThanhVien", null);
            %>
        </center>
    </div>

</center>